<?php 
	Configure::write('debug',0);
	if($session->check("Message.ajax"))
	{
		echo 'alert("'.$session->read("Message.ajax.message").'");';
		$session->del("Message.ajax");
	}
?>
<?php 
// update vote score
$this->layout = false;
if(isset($voteData))
{
	if($voteData['score']=='-1')
	{
		$score = '-1';
		$div_to_update = 'voteDown';
	}
	else
	{
		$score = '1';
		$div_to_update = 'voteUp';
	}
?>
	currentScore = $('#vote-<?php echo $voteData['item_id'];?>-<?php echo $voteData['type'];?> .<?php echo $div_to_update;?>').html();
	if(currentScore)
	{
		currentScore = parseInt(currentScore)+1;
		currentScore = $('#vote-<?php echo $voteData['item_id'];?>-<?php echo $voteData['type'];?> .<?php echo $div_to_update;?>').html(currentScore);
	}
	else
	{	// for digg voting style
		currentScore = $('#vote-<?php echo $voteData['item_id'];?>-<?php echo $voteData['type'];?> .votesCount').html();
		currentScore = parseInt(currentScore)+<?php echo $score;?>;

		$('#vote-<?php echo $voteData['item_id'];?>-<?php echo $voteData['type'];?> .votesCount').html(currentScore);
	}
	
	totalVotes = $('#vote-<?php echo $voteData['item_id'];?>-<?php echo $voteData['type'];?> .totalVotes').html();
	if(totalVotes)
	{
		totalVotes = parseInt(totalVotes)+1;
		totalVotes = $('#vote-<?php echo $voteData['item_id'];?>-<?php echo $voteData['type'];?> .totalVotes').html(totalVotes);
	
	}
	if($.isFunction('afterVoteAdd'))
	{
		<?php 
			$voteInfo = array_intersect_key($voteData,array('item_id'=>'','score'=>'','type'=>''));
			unset($voteInfo['id']);
		?>
		var voteInfo = <?php echo $javascript->object($voteInfo)?>;
		voteInfo["voteUp"] = <?php echo $voteUp;?>;
		voteInfo["voteDown"] = <?php echo $voteDown;?>;
		afterVoteAdd(voteInfo);
	}
<?php 
} 
?>